<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:useBean id="member" class="oneroom.admin.member.MemberDao" scope="page"/>
<jsp:useBean id="code" class="oneroom.admin.code.codeDao" scope="page"/>
<%@ page import="oneroom.admin.member.MemberModel" %>
<%@ page import="oneroom.admin.code.codeModel" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.List" %>
<%
	HashMap	paramMap = new HashMap();
	int		giSelectPage  	= Integer.parseInt(request.getParameter("txtSelectPage") == null ? "0" :request.getParameter("txtSelectPage"));			//현재 선택된 페이지 저장
	int		giSelectBlock 	= Integer.parseInt(request.getParameter("txtSelectBlock") == null ? "0" :request.getParameter("txtSelectBlock"));			//현재 선택된 블락페이지 저장
	String	searchGubn		= request.getParameter("searchGubn") == null ? "" : request.getParameter("searchGubn");
	String	searchValue		= request.getParameter("searchValue") == null ? "" : request.getParameter("searchValue");
	String	id				= request.getParameter("id") == null ? "" : request.getParameter("id");
	
	paramMap.put("id",id);
	
	ArrayList returnList	=  member.getView(paramMap);
	MemberModel model	= new MemberModel();
	List list1 = code.getDtlList("100");
	List list2 = code.getDtlList("101");
	if(returnList != null && returnList.size() > 0){
		model = (MemberModel)returnList.get(0);		
	}
	
	String mode = request.getParameter("mode") == null ? "I" : request.getParameter("mode");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>회원관리</title>
<script type="text/javascript" src="/admin/js/default.js"></script>
<script type="text/javascript" src="/admin/js/jquery-1.3.2.min.js"></script>
<link href="/admin/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
var id = "";
$(document).ready(function(){
	
	<% if (mode.equals("I")){%>
	$('#email3').hide();
	<%}%>	
	$('#lstBtn').click(function() {
		window.location="list.jsp";
	});
  
	$('#email2').change(function(){
	var val = $('#email2 > option:selected').val();
		if(val == ''){
	      $('#email3').show();
		}else{
		  $('#email3').hide();
		}    
	});  

	$('#idBtn').click(function() {
		window.open("id_check.jsp","idcheck","Width=520,Height=350");
	});
	
});
	function chkPassword(){
		  var obj = document.getElementById("pwd");
		  if(obj.value.search(/[^a-zA-Z0-9-_]/g) != -1){
		    alert('영문이나 숫자만 입력하실 수 있습니다');
		    obj.value = '';
		    return false;
		  }  
		  return true;
	}
		
	function chechk(){
		if($("#id").val() == "" ){
			alert("ID을 입력하세요.");
			return false;
		}else if($("#name").val() == ""){
			alert("이름을 입력하세요.");
			return false;
		}else if($("#pwd").val() == "" ){
			alert("비밀번호을 입력하세요.");
			return false;
		//}else if($("#repwd").val() == ""){
		//	alert("비밀번호확인을 하세요.");
		//	return false;
		//}else if($("#pwd").val() != $("#repwd").val()){
		//	alert("비밀번호확인을 하세요.");
		//	return false;
		}else if($("#tel1").val() == "" && $("#tel2").val() == "" && $("#tel3").val() == "" ){
			alert("전화번호를 입력하세요.");
			return false;
		}else if($("#hp1").val() == "" && $("#hp2").val() == "" && $("#hp3").val() == "" ){
			alert("전화번호를 입력하세요.");
			return false;
		}else if($("#email1").val() == "" && ($("#email2").val() == "" || $("#email3").val() == "") ){
			alert("E-mail를 입력하세요.");
			return false;
		}else if($("#email2").val() == "" ){
			alert("E-mail를 입력하세요.");
			return false;
		}else if(!isEng($("#email1").val())){
			alert("영문숫자만 가능합니다.");
			return false;
		}else if(!isEng($("#pwd").val())){
			alert("영문숫자만 가능합니다.");
			return false;
		}else{
		return true;
		}
	}
	
//-->
</script>
</head>
<body>
<!-- Header  Start -->
<div id="bodywrap">
<div class="all-wrap">
<%@ include file="/admin/common/top.jsp" %>
<div id="right-wrap">
<%@ include file="/admin/common/navi.jsp" %>
<!--Contents Start-->
<div id="content">
<div class="path"><span>home</span> >  회원관리 </div>
<h4>회원</h4>
<p class="sub-text">회원 관리 하실 수 있습니다.</p>
<form name="frm" id="frm" action="dbx.jsp" method="post" onsubmit="return chechk();" >
<input type="hidden" name="mode" value="<%=mode%>" />
<input type="hidden" name="searchGubn" value="<%=searchGubn %>" />
<input type="hidden" name="searchValue" value="<%=searchValue %>" />
<input type="hidden" name="txtSelectPage" value="<%=giSelectPage %>" />
<input type="hidden" name="txtSelectBlock" value="<%=giSelectBlock %>" />
<input type="hidden" name="idx" value="<%=model.getIdx() %>" />
<input type="hidden" name="id" value="<%=model.getId() %>" />
<input type="hidden" name="hiddenid" value="" />

<table class="view-normal" cellpadding="0" cellspacing="0" summary="EVENT" >
        <caption>회원</caption>
          <col width="70px" />
          <col width="528px" />
          <tbody>
            <tr>
              <th scope="row" >이름</th>
              <td colspan="3"><input name="name" id="name" value="<%=model.getName() %>" title="이름" type="text" maxlength="10" style="width:150px;" disabled="disabled"/></td>
            </tr>
            <!-- tr>
              <th scope="row" >주민번호</th>
              <td colspan="3">
              <%//if(!model.getJumin().equals("")){%>	
              <input name="jumin1" id="jumin1" value="<%//=model.getJumin().substring(0,6) %>" title="주민번호1" type="text" maxlength="6" style="width:100px;" />&nbsp;-&nbsp;
              <input name="jumin2" id="jumin2" value="<%//=model.getJumin().substring(6,13) %>" title="주민번호2" type="text" maxlength="7" style="width:100px;" />
              <%//}else{ %>  
              <input name="jumin1" id="jumin1" value="" title="주민번호1" type="text" maxlength="6" style="width:100px;" />&nbsp;-&nbsp;
              <input name="jumin2" id="jumin2" value="" title="주민번호2" type="text" maxlength="7" style="width:100px;" />
              <%//} %>
              </td>
            </tr> -->
            <tr>
              <th scope="row" >ID</th>
              <td colspan="3"><input name="id" id="id" value="<%=model.getId() %>" title="아이디" type="text" maxlength="12" style="width:150px;" disabled="disabled" />&nbsp;<input type="button" value="ID중복체크" class="btn-bg-gray" id="idBtn" /></td>
            </tr>      
            <tr>
              <th scope="row" >비밀번호</th>
              <td colspan="3"><input name="pwd" id="pwd" value="<%=model.getPwd() %>" title="비밀번호" type="password" maxlength="12" style="width:100px;" /></td>
            </tr>                  
            <!-- tr>
              <th scope="row" >비밀번호 확인</th>
              <td colspan="3"><input name="repwd" id="repwd" value="" title="비밀번호확인" type="password" maxlength="12" style="width:100px;" /></td>
            </tr -->                  
            <tr>
              <th scope="row" >전화번호</th>
              <td colspan="3">	
              <%if(!model.getTel().equals("")){
              		if(model.getTel().startsWith("02")){
                    	if(model.getTel().length() > 9){
              %>
			  <input name="tel1" id="tel1" value="<%=model.getTel().substring(0,2) %>" title="전화번호" type="text" maxlength="3" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="tel2" id="tel2" value="<%=model.getTel().substring(2,6) %>" title="전화번호" type="text" maxlength="4" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="tel3" id="tel3" value="<%=model.getTel().substring(7,model.getTel().length()) %>" title="전화번호" type="text" maxlength="4" style="width:80px;" />
              <%
                    	}else{
              %>
			  <input name="tel1" id="tel1" value="<%=model.getTel().substring(0,2) %>" title="전화번호" type="text" maxlength="3" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="tel2" id="tel2" value="<%=model.getTel().substring(2,5) %>" title="전화번호" type="text" maxlength="4" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="tel3" id="tel3" value="<%=model.getTel().substring(5,model.getTel().length()) %>" title="전화번호" type="text" maxlength="4" style="width:80px;" />               
              <%
                    	}
               		}else{
               			if(model.getTel().length() > 10){               			
			  %>
			  <input name="tel1" id="tel1" value="<%=model.getTel().substring(0,3) %>" title="전화번호" type="text" maxlength="3" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="tel2" id="tel2" value="<%=model.getTel().substring(3,7) %>" title="전화번호" type="text" maxlength="4" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="tel3" id="tel3" value="<%=model.getTel().substring(7,model.getTel().length()) %>" title="전화번호" type="text" maxlength="4" style="width:80px;" />			   
			  <%
                      	}else{
              %>
                     		
              			  <input name="tel1" id="tel1" value="<%=model.getTel().substring(0,3) %>" title="전화번호" type="text" maxlength="3" style="width:80px;" />&nbsp;-&nbsp;   
            			  <input name="tel2" id="tel2" value="<%=model.getTel().substring(3,6) %>" title="전화번호" type="text" maxlength="4" style="width:80px;" />&nbsp;-&nbsp;   
            			  <input name="tel3" id="tel3" value="<%=model.getTel().substring(6,model.getTel().length()) %>" title="전화번호" type="text" maxlength="4" style="width:80px;" />                      		
      		  <% 
                      }
                    }              
                }else{ 
              %>     
			  <input name="tel1" id="tel1" value="" title="전화번호" type="text" maxlength="3" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="tel2" id="tel2" value="" title="전화번호" type="text" maxlength="4" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="tel3" id="tel3" value="" title="전화번호" type="text" maxlength="4" style="width:80px;" />
			  </td>
			  <%} %>
            </tr>
            <tr>
              <th scope="row" >휴대폰번호</th>
              <td colspan="3">	
              <%if(!model.getTel().equals("")){%>			
              <select id="hp1" name="hp1" class="mg-l45" style="width:	80px;">
				<option value="010" <%if(model.getHp().substring(0,3).equals("010")){out.println("selected");} %>>010</option>
				<option value="011" <%if(model.getHp().substring(0,3).equals("011")){out.println("selected");} %>>011</option>
				<option value="016" <%if(model.getHp().substring(0,3).equals("016")){out.println("selected");} %>>016</option>
				<option value="017" <%if(model.getHp().substring(0,3).equals("017")){out.println("selected");} %>>017</option>
				<option value="018" <%if(model.getHp().substring(0,3).equals("018")){out.println("selected");} %>>018</option>
				<option value="019" <%if(model.getHp().substring(0,3).equals("019")){out.println("selected");} %>>019</option>
			  </select>
			  &nbsp;-&nbsp;
             	 <%if(model.getHp().length() > 10){ %>   			  
			  <input name="hp2" id="hp2" value="<%=model.getHp().substring(3,7) %>" title="핸드폰" type="text" maxlength="4" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="hp3" id="hp3" value="<%=model.getHp().substring(7,model.getHp().length()) %>" title="핸드폰" type="text" maxlength="4" style="width:80px;" />
				  <%}else{ %>
			  <input name="hp2" id="hp2" value="<%=model.getHp().substring(3,6) %>" title="핸드폰" type="text" maxlength="4" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="hp3" id="hp3" value="<%=model.getHp().substring(6,model.getHp().length()) %>" title="핸드폰" type="text" maxlength="4" style="width:80px;" />
				  
				  <%} %>
			  <%}else{ %>     
              <select id="hp1" name="hp1" class="mg-l45" style="width:	80px;">
				<option value="010">010</option>
				<option value="011">011</option>
				<option value="016">016</option>
				<option value="017">017</option>
				<option value="018">018</option>
				<option value="019">019</option>
			  </select>
			  &nbsp;-&nbsp;
			  <input name="hp2" id="hp2" value="" title="핸드폰" type="text" maxlength="4" style="width:80px;" />&nbsp;-&nbsp;   
			  <input name="hp3" id="hp3" value="" title="핸드폰" type="text" maxlength="4" style="width:80px;" />
			  </td>
			  <%}%>  
            </tr>
            <tr>
              <th scope="row" >사용자 구분</th>
              <td colspan="3">
		        <select id="select-grade" class="selectMain" style="width: 120px;" name="authorize">
				<%
				for(int i = 0; i<list1.size(); i++){
					codeModel codemodel = (codeModel)list1.get(i);
					
				%>
				      <option value="<%=codemodel.getCode() %>" <%if(codemodel.getCode().equals(model.getAuthorize())){%>selected="selected"<%}%>><%=codemodel.getCodename()%></option>
				<%
				} 
				%> 	
				</select>              
			  </td>              
            </tr>              
            <tr>
              <th scope="row" >사용자등급</th>
              <td colspan="3">
		        <select id="select-grade" class="selectMain" style="width: 80px;" name="grade">
				<%
				for(int i = 0; i<list2.size(); i++){
					codeModel codemodel = (codeModel)list2.get(i);
					
				%>
				      <option value="<%=codemodel.getCode() %>" <%if(codemodel.getCode().equals(model.getGrade())){%>selected="selected"<%}%>><%=codemodel.getCodename()%></option>
				<%
				} 
				%> 	
				</select>
			  </td>              
            </tr>              
			<tr>
			  <th scope="row" >이메일</th>
			  <td colspan="3">
			  <%
			  if(!model.getEmail().equals("")){
              String email[] = model.getEmail().split("@");
              String tmpEmail = "";
              
              if (email[1].equals("hanmail.net")){
               email[1] = "1";
              }else if (email[1].equals("naver.com")){
               email[1] = "2";
              }else if (email[1].equals("yahoo.com")){
               email[1] = "3";
              }else if (email[1].equals("hotmail.com")){
               email[1] = "4";
              }else if (email[1].equals("nate.com")){
               email[1] = "5";
              }else if (email[1].equals("paran.com")){
               email[1] = "6";
              }else if (email[1].equals("dreamwiz.com")){
               email[1] = "7";
              }else if (email[1].equals("empal.com")){
               email[1] = "8";
              }else{
               tmpEmail = email[1];
               email[1] = "9";
              }
			  %>
			    <input type="text" id="email1" name="email1" value="<%=email[0] %>" style="width:60px;ime-mode:inactive;" />
				@
	            <select id="email2" name="email2">
	                <option value="">선택하세요.</option>
	                <option value="" <%if(email[1].equals("9")){ %>selected="selected"<%} %>>직접입력</option>
	                <option value="hanmail.net" <%if(email[1].equals("1")){ %>selected="selected"<%} %>>hanmail.net</option>
					<option value="naver.com" <%if(email[1].equals("2")){ %>selected="selected"<%} %>>naver.com</option>
					<option value="yahoo.com" <%if(email[1].equals("3")){ %>selected="selected"<%} %>>yahoo.com</option>
					<option value="hotmail.com" <%if(email[1].equals("4")){ %>selected="selected"<%} %>>hotmail.com</option>
					<option value="nate.com" <%if(email[1].equals("5")){ %>selected="selected"<%} %>>nate.com</option>
					<option value="paran.com" <%if(email[1].equals("6")){ %>selected="selected"<%} %>>paran.com</option>
					<option value="dreamwiz.com" <%if(email[1].equals("7")){ %>selected="selected"<%} %>>dreamwiz.com</option>
					<option value="empal.com" <%if(email[1].equals("8")){ %>selected="selected"<%} %>>empal.com</option>
	            </select>&nbsp;
	            <input type="text" id="email3" name="email3" value="<%=tmpEmail %>" style="width:60px;" />
			<%}else{ %>
			    <input type="text" id="email1" name="email1" value="" style="width:60px;" />
				@
	            <select id="email2" name="email2">
	                <option value="">선택하세요.</option>
	                <option value="">직접입력</option>
	                <option value="hanmail.net">hanmail.net</option>
					<option value="naver.com">naver.com</option>
					<option value="yahoo.com">yahoo.com</option>
					<option value="hotmail.com">hotmail.com</option>
					<option value="nate.com">nate.com</option>
					<option value="paran.com">paran.com</option>
					<option value="dreamwiz.com">dreamwiz.com</option>
					<option value="empal.com">empal.com</option>
	            </select>&nbsp;
	            <input type="text" id="email3" name="email3" value="" style="width:60px;ime-mode:inactive;" />
			<%}%>			 
			  </td>
			</tr> 			
          </tbody>       
</table>
<div class="btn-all-align2">
<span class="btn-align"><input type="submit" value="등록" class="btn-bg-gray"  /></span>
<span class="btn-align"><input type="button" value="목록" class="btn-bg-gray" id="lstBtn" /></span>
</div>
</form>
<!--Contents End-->
</div>
</div>
</div>
<!--Footer Start-->
<%@ include file="/admin/common/bottom.jsp" %>
<!--Footer End-->
</body>
</html>